package com.lonely.fx;

import javafx.application.Application;
import javafx.collections.ObservableList;
import javafx.geometry.Rectangle2D;
import javafx.stage.Screen;
import javafx.stage.Stage;

/**
 * @author 独孤小标
 * @description screen --屏幕类，获取屏幕相关信息
 * @since 2022/6/21 10:26 下午
 */
public class ScreenSettingMain extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    /**
     *
     */
    @Override
    public void start(Stage primaryStage) throws Exception {

        //获取主屏幕对象
        Screen primary = Screen.getPrimary();

        //获取屏幕宽高坐标
        Rectangle2D bounds = primary.getBounds();
        System.out.print("以下是总屏幕的数据信息");
        System.out.printf("左上角x：%s， 左上角y：%s%n",bounds.getMinX(),bounds.getMinY());
        System.out.printf("右下角x：%s， 右下角y：%s%n",bounds.getMaxX(),bounds.getMaxY());
        System.out.printf("宽：%s， 高：%s%n",bounds.getWidth(),bounds.getHeight());

        System.out.println("\n");

        //获取可视屏幕的宽高坐标
        Rectangle2D visualBounds = primary.getVisualBounds();
        System.out.print("以下是可视屏幕的数据信息");
        System.out.printf("左上角x：%s， 左上角y：%s%n",visualBounds.getMinX(),visualBounds.getMinY());
        System.out.printf("右下角x：%s， 右下角y：%s%n",visualBounds.getMaxX(),visualBounds.getMaxY());
        System.out.printf("宽：%s， 高：%s%n",visualBounds.getWidth(),visualBounds.getHeight());

        //获取屏幕对象集合，因为可能连接了多个屏幕
        ObservableList<Screen> screens = Screen.getScreens();
        System.out.println(screens.size());


    }
}
